mod config;
mod service;
pub use config::Config;
pub use service::Command;
pub use service::Service;
use std::collections::HashMap;

pub struct AppState {
    pub configs: Config,
    pub srv: HashMap<Command, Service>,
}

impl AppState {
    pub fn new() -> Self {
        Self {
            configs: Config::default(),
            srv: HashMap::new(),
        }
    }

    pub fn kill_all_service(&mut self) {
        let keys = self.srv.keys().cloned().collect::<Vec<_>>();

        for v in keys {
            if let Some(v) = self.srv.remove(&v) {
                v.kill().unwrap();
            }
        }
    }
}
